<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>课堂随机点名系统</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            background-color: #f0f0f0;
            min-height: 100vh;
            margin: 0;
            padding: 20px;
        }

        .container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
            width: 80%;
            max-width: 600px;
        }

        #display {
            font-size: 3em;
            text-align: center;
            margin: 20px 0;
            color: #2c3e50;
            min-height: 100px;
        }

        button {
            padding: 15px 30px;
            font-size: 1.2em;
            background-color: #3498db;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            transition: background-color 0.3s;
            margin: 10px;
        }

        button:hover {
            background-color: #2980b9;
        }

        .student-list {
            margin-top: 20px;
            padding: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        .highlight {
            color: #e74c3c;
            font-weight: bold;
            animation: blink 0.5s ease infinite;
        }

        @keyframes blink {
            50% { opacity: 0.5; }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>课堂随机点名系统</h1>
        <div id="display">点击开始</div>
        <div style="text-align: center;">
            <button id="startBtn">开始/停止</button>
        </div>
        
        <div class="student-list">
            <h3>学生名单</h3>
            <ul id="studentList"></ul>
        </div>
    </div>

    <script>
        // 学生名单（可以自行修改或扩展）
        const students = [
            "吴龙飞", "谢佳康", "王鹏举", "孔毅",
            "位家乐",
        ];

        let isRunning = false;
        let intervalId = null;
        const display = document.getElementById('display');
        const startBtn = document.getElementById('startBtn');
        const studentList = document.getElementById('studentList');

        // 初始化学生名单
        students.forEach(student => {
            const li = document.createElement('li');
            li.textContent = student;
            studentList.appendChild(li);
        });

        function getRandomStudent() {
            return students[Math.floor(Math.random() * students.length)];
        }

        function updateDisplay() {
            display.textContent = getRandomStudent();
        }

        function toggleRolling() {
            if (isRunning) {
                // 停止
                clearInterval(intervalId);
                display.classList.add('highlight');
                startBtn.textContent = '重新开始';
            } else {
                // 开始
                display.classList.remove('highlight');
                intervalId = setInterval(updateDisplay, 50);
                startBtn.textContent = '停止';
            }
            isRunning = !isRunning;
        }

        startBtn.addEventListener('click', toggleRolling);

        // 初始显示
        updateDisplay();
    </script>
</body>
</html>